package cn.lyjuan.payment.third.base.pay.enums;

import lombok.Getter;

@Getter
public enum IosNotifyTypeEnum {
    /**
     * 表示Apple客户支持取消了自动更新订阅，或者用户升级了他们的自动更新订阅。该密钥包含的变化的日期和时间。cancellation_date
     */
    CANCEL("CANCEL", "Indicates that either Apple customer support canceled the auto-renewable subscription or the user upgraded their auto-renewable subscription. The cancellation_date key contains the date and time of the change."),
    /**
     * 表示Apple客户支持取消了自动更新订阅，或者用户升级了他们的自动更新订阅。该密钥包含的变化的日期和时间。cancellation_date
     */
    DID_CHANGE_RENEWAL_PREF("DID_CHANGE_RENEWAL_PREF", "Indicates that the customer made a change in their subscription plan that takes effect at the next renewal. The currently active plan isn’t affected."),
    /**
     * 指示订阅续订状态的更改。在JSON响应中，检查以了解上一次状态更新的日期和时间。检查以了解当前的续订状态.auto_renew_status_change_date_msauto_renew_status
     */
    DID_CHANGE_RENEWAL_STATUS("DID_CHANGE_RENEWAL_STATUS", "Indicates a change in the subscription renewal status. In the JSON response, check auto_renew_status_change_date_ms to know the date and time of the last status update. Check auto_renew_status to know the current renewal status."),
    /**
     * 表示由于计费问题而无法续订的订阅。检查以了解订阅的当前重试状态。如果订阅处于计费宽限期内，请检查以了解新服务的到期日期.is_in_billing_retry_periodgrace_period_expires_date
     */
    DID_FAIL_TO_RENEW("DID_FAIL_TO_RENEW", "Indicates a subscription that failed to renew due to a billing issue. Check is_in_billing_retry_period to know the current retry status of the subscription. Check grace_period_expires_date to know the new service expiration date if the subscription is in a billing grace period."),
    /**
     * 表示成功的自动更新已过期的订阅，而该订阅过去未能续订。检查以确定下一个续订日期和时间。expires_date
     */
    DID_RECOVER("DID_RECOVER", "Indicates a successful automatic renewal of an expired subscription that failed to renew in the past. Check expires_date to determine the next renewal date and time."),
    /**
     * 指示客户的订阅已成功成功自动续订了一个新的交易时段。
     */
    DID_RENEW("DID_RENEW", "Indicates that a customer’s subscription has successfully auto-renewed for a new transaction period."),
    /**
     * 在用户最初购买订阅时发生。通过令牌存储在服务器上，可以随时通过App Store验证用户的订阅状态。latest_receipt
     */
    INITIAL_BUY("INITIAL_BUY", "Occurs at the user’s initial purchase of the subscription. Store latest_receipt on your server as a token to verify the user’s subscription status at any time by validating it with the App Store."),
    /**
     * 指示客户使用您的应用程序界面或在该帐户的“订阅”设置中的App Store上以交互方式续订订阅。立即提供服务。
     */
    INTERACTIVE_RENEWAL("INTERACTIVE_RENEWAL", "Indicates the customer renewed a subscription interactively, either by using your app’s interface, or on the App Store in the account’s Subscriptions settings. Make service available immediately."),
    /**
     * 表示App Store已开始要求客户同意您的应用的订阅价格上涨。在Unified_receipt.Pending_renewal_info对象中，值为，表示App Store正在征求客户的同意，但尚未收到客户的同意。除非用户同意新价格，否则订阅不会自动续订。当客户同意提价时，系统设置为。使用verifyReceipt检查收据以查看更新的价格同意状态。price_consent_status0price_consent_status1
     */
    PRICE_INCREASE_CONSENT("DID_FAIL_TO_RENEW", "Indicates that App Store has started asking the customer to consent to your app’s subscription price increase. In the unified_receipt.Pending_renewal_infoobject, the price_consent_status value is 0, indicating that App Store is asking for the customer’s consent, and hasn’t received it. The subscription won’t auto-renew unless the user agrees to the new price. When the customer agrees to the price increase, the system sets price_consent_status to 1. Check the receipt using verifyReceipt to view the updated price-consent status."),
    /**
     * REFUND 表示App Store成功退还了可消耗或不可消耗的应用内购买交易。该包含退回的交易的时间戳。该和识别原始交易和产品。该包含的原因。cancellation_date_msoriginal_transaction_idproduct_idcancellation_reason
     */
    REFUND("REFUND", "Indicates that App Store successfully refunded a transaction for a consumable or non-consumable in-app purchase. The cancellation_date_ms contains the timestamp of the refunded transaction. The original_transaction_id and product_id identify the original transaction and product. The cancellation_reason contains the reason."),
    /**
     * RENEWAL (DEPRECATED IN SANDBOX) 表示成功的自动更新已过期的订阅，而该订阅过去未能续订。检查以确定下一个续订日期和时间。此通知在沙盒环境中已弃用，计划于2021年3月在生产中弃用。更新现有代码以改为依靠通知类型。expires_dateDID_RECOVER
     */
    RENEWAL("RENEWAL ", "Indicates a successful automatic renewal of an expired subscription that failed to renew in the past. Check expires_date to determine the next renewal date and time. This notification is deprecated in the sandbox environment, and scheduled for deprecation in production in March 2021. Update your existing code to rely on DID_RECOVER notification type instead."),
    /**
     * REVOKE 表示用户不再可以通过“家庭共享”获得应用内购买。当购买者禁用产品的家庭共享，购买者（或家庭成员）离开家庭组或购买者要求并收到退款时，StoreKit会发送此通知。您的应用也会收到电话。有关家庭共享的更多信息，请参阅在应用程序中支持家庭共享。
     */
    REVOKE("REVOKE", "Indicates that an in-app purchase the user was entitled to through Family Sharing is no longer available through sharing. StoreKit sends this notification when a purchaser disabled Family Sharing for a product, the purchaser (or family member) left the family group, or the purchaser asked for and received a refund. Your app will also receive a paymentQueue(_:didRevokeEntitlementsForProductIdentifiers:)call. For more information about Family Sharing, see Supporting Family Sharing in Your App."),
    //
    ;

    private String type;
    private String desc;

    IosNotifyTypeEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    /**
     * 根据type找到Enum
     *
     * @param type type
     * @return IosNotifyTypeEnum
     */
    public static IosNotifyTypeEnum findByType(String type) {
        if (type == null) {
            return null;
        }
        for (IosNotifyTypeEnum tmpEnum : values()) {
            if (tmpEnum != null && tmpEnum.getType().equals(type)) {
                return tmpEnum;
            }
        }
        return null;
    }

}
